import eachDeep from 'deepdash/eachDeep';

const routes = [
  {
    path: '/login',
    component: './login',
  },
  {
    path: '/',
    component: '../layouts/SecurityLayout',
    routes: [
      {
        path: '/',
        component: '../layouts/BasicLayout',
        routes: [
          {
            path: '/',
            redirect: '/projtrack',
          },
          {
            name: '项目跟踪',
            icon: 'FormOutlined',
            path: '/projtrack',
            component: './projtrack',
            //authority: ['admin'],
            // access: 'canAdmin',
          },
          {
            name: '问题管理',
            icon: 'AlertOutlined',
            path: '/problem',
            component: './problem',
            //authority: ['admin'],
          },
          {
            name: '用户管理',
            icon: 'UserOutlined',
            path: '/user',
            component: './user',
            //authority: ['admin'],
          },
          {
            path: '/403',
            component: './403',
            //authority: ['admin'],
          },
        ],
      },
    ],
  },
];

export default eachDeep(
  routes,
  (value, key, parentValue, { depth }) => {
    if (depth >= 2 && value.routes) {
      value.routes.push({ component: './404' });
    }
  },
  { childrenPath: 'routes' },
);
